<?php

use think\migration\Migrator;
use think\migration\db\Column;

class UserEquity extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table  =  $this->table('equity',array('comment'=>'订单分润表'));
        $table->addColumn('user_id', 'integer',array('limit'  => 11,'default'=>0,'comment'=>'用户id',"null"=>true))
        ->addColumn('order_id', 'integer',array('limit'  => 11,'default'=>0,'comment'=>'订单ID',"null"=>true))
        ->addColumn('order_fee', 'float', array('limit' => "10,2",'default'=>0,"comment"=>"订单收入","null"=>true))
        ->addColumn('unit_percentage', 'float', array('limit' => "10,2",'default'=>0,"comment"=>"分成比例","null"=>true))
        ->addColumn('fee', 'float', array('limit' => "10,2",'default'=>0,"comment"=>"分润金额","null"=>true))
        ->addColumn('prime_price', 'float', array('limit' => "10,2",'default'=>0,"comment"=>"商品成本","null"=>true))
        ->addColumn('status', 'enum',array('values' => "0,1,2,3,4","comment"=>"状态:0=审核中,1=保单确认中,2=确认成功,3=确认失败,4=退保","null"=>true))
        ->addColumn('channel', 'enum',array('values' => "0,1,2","comment"=>"渠道:0=其他订单,1=云栖订单,2=语雀订单","null"=>true))
        ->addColumn('date', 'integer',array('limit'  => 11,'default'=>0,'comment'=>'分润日期',"null"=>true))
        ->addColumn('createtime', 'integer', array('limit' => 10,"comment"=>"新增时间","null"=>true))
        ->addColumn('updatetime', 'integer', array('limit' => 10,"comment"=>"更新时间","null"=>true))
        ->addIndex(array('user_id'))
        ->addIndex(array('order_id'))
        ->addIndex(array('date'))
        ->create();
    }
}
